package 力扣日常刷题.木23一月.第02天302;

import java.util.Scanner;

/**
 * @author 帅小伙
 * @date 2022/3/2
 * @description
 */
public class Demo19小团的神秘暗号 {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =  sc.nextInt();
        String str = sc.next();

        int l = 0;
        while(str.charAt(l) != 'M') l++;
        while(str.charAt(l) != 'T') l++;
        int r = n - 1;
        while(str.charAt(r) != 'T') r -- ;
        while(str.charAt(r) != 'M') r --;

        System.out.println(str.substring(l+1,r));
    }


}
